package com.cez.itstudio01.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.sun.org.apache.bcel.internal.generic.RETURN;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 
 * @TableName user
 */
@TableName(value ="user")
public class User implements Serializable {
    /**
     * 
     */
    @TableId("ID")
    private String id;

    /**
     * 
     */
    private String name;

    /**
     * 
     */
    private String password;

    /**
     * 
     */
    private String limit;

    /**
     * 
     */
    private Integer grade;

    /**
     * 
     */
    @TableField("book1_ID")
    private String book1Id;

    /**
     * 
     */
    @TableField("book2_ID")
    private String book2Id;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    //返回可借数
    public int getUserNowNum(){
        List list = new ArrayList();
        list.add(book1Id);
        list.add(book2Id);
        if(list.get(0)==null&list.get(1)==null){
            return 2;
        }
        if(list.get(1)==null){
            return 1;
        }
        else {
            return 0;
        }
    }
    /**
     * 
     */
    public String getId() {
        return id;
    }

    /**
     * 
     */
    public void setId(String id) {
        this.id = id;
    }

    /**
     * 
     */
    public String getName() {
        return name;
    }

    /**
     * 
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * 
     */
    public String getPassword() {
        return password;
    }

    /**
     * 
     */
    public void setPassword(String password) {
        this.password = password;
    }

    /**
     * 
     */
    public String getLimit() {
        return limit;
    }

    /**
     * 
     */
    public void setLimit(String limit) {
        this.limit = limit;
    }

    /**
     * 
     */
    public Integer getGrade() {
        return grade;
    }

    /**
     * 
     */
    public void setGrade(Integer grade) {
        this.grade = grade;
    }

    /**
     * 
     */
    public String getBook1Id() {
        return book1Id;
    }

    /**
     * 
     */
    public void setBook1Id(String book1Id) {
        this.book1Id = book1Id;
    }

    /**
     * 
     */
    public String getBook2Id() {
        return book2Id;
    }

    /**
     * 
     */
    public void setBook2Id(String book2Id) {
        this.book2Id = book2Id;
    }

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        User other = (User) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()))
            && (this.getPassword() == null ? other.getPassword() == null : this.getPassword().equals(other.getPassword()))
            && (this.getLimit() == null ? other.getLimit() == null : this.getLimit().equals(other.getLimit()))
            && (this.getGrade() == null ? other.getGrade() == null : this.getGrade().equals(other.getGrade()))
            && (this.getBook1Id() == null ? other.getBook1Id() == null : this.getBook1Id().equals(other.getBook1Id()))
            && (this.getBook2Id() == null ? other.getBook2Id() == null : this.getBook2Id().equals(other.getBook2Id()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
        result = prime * result + ((getPassword() == null) ? 0 : getPassword().hashCode());
        result = prime * result + ((getLimit() == null) ? 0 : getLimit().hashCode());
        result = prime * result + ((getGrade() == null) ? 0 : getGrade().hashCode());
        result = prime * result + ((getBook1Id() == null) ? 0 : getBook1Id().hashCode());
        result = prime * result + ((getBook2Id() == null) ? 0 : getBook2Id().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", name=").append(name);
        sb.append(", password=").append(password);
        sb.append(", limit=").append(limit);
        sb.append(", grade=").append(grade);
        sb.append(", book1Id=").append(book1Id);
        sb.append(", book2Id=").append(book2Id);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }

    public User(String id, String name, String password, String limit, Integer grade, String book1Id, String book2Id) {
        this.id = id;
        this.name = name;
        this.password = password;
        this.limit = limit;
        this.grade = grade;
        this.book1Id = book1Id;
        this.book2Id = book2Id;
    }
}